// 2025/3/26
// https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/description/?envType=study-plan-v2&envId=top-100-liked
// 买卖股票的最佳时机

class Solution {
    public:
        int maxProfit(vector<int>& prices) {
            int lowest = prices[0], Mpro = 0, n = prices.size();
            for(int i = 0; i < n; i++)
            {
                if(prices[i] > lowest)
                    Mpro = max(Mpro, prices[i] - lowest);
                else
                    lowest = prices[i];
            }
            return Mpro;
        }
    };